package Services.Impl;

import bluej.extensions.*;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JMenuItem;

/**
 * 
 * @author jose.luz
 */
public class BlueJService extends Extension{
    private static String name = "Editor do Diagrama de Comunicações";
    private BlueJ bluej;
    
    @Override
    public void startup(BlueJ bluej) {
        this.bluej = bluej;
        BlueJMenu menu = new BlueJMenu(this);
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public String getVersion() {
        return "1.0";
    }   
    
    @Override
    public boolean isCompatible() {
        return true;
    }
}

class BlueJMenu extends MenuGenerator{
	private MenuAction menuAction;
	private BlueJService service;

	public BlueJMenu(BlueJService service)
	{
            this.service = service;
            menuAction = new MenuAction(service.getName(), service);
	}

        @Override
	public JMenuItem getToolsMenuItem(BPackage bp)
	{
            return new JMenuItem(menuAction);
	}

	class MenuAction extends AbstractAction
	{
            private BlueJService service;

            public MenuAction(String menuName, BlueJService service)
            {
                this.service = service;
                putValue (AbstractAction.NAME, menuName);
            }

            public void actionPerformed(ActionEvent anEvent)
            {
                //TODO: Open the View. new EditorComunicacoes(simple.getBlueJ());
            }
	}
}